package edu.ncst.baseweb.service;

import edu.ncst.baseweb.dao.User;
import edu.ncst.baseweb.dto.JwtUser;
import edu.ncst.baseweb.mapper.UserMapper;
import edu.ncst.baseweb.service.intrer.CustomUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * 登陆身份认证
 */
@Service
public class CustomUserDetailsServiceImpl implements CustomUserDetailsService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

        User user = userMapper.findByUserAccount(username);

        return new JwtUser(user);

    }
}
